package com.chat.login.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chat.common.entity.UserFeedback;
import com.chat.login.domain.dto.UserFeedbackDTO;
import com.chat.login.mapper.UserFeedbackMapper;
import com.chat.login.service.IUserFeedbackService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author weikjie
 * @since 2024-05-13
 */
@Service
public class UserFeedbackServiceImpl extends ServiceImpl<UserFeedbackMapper, UserFeedback> implements IUserFeedbackService {

    @Override
    public List<UserFeedback> getUserFeedbacksList(String account) {
        return baseMapper.selectList(new QueryWrapper<UserFeedback>().eq("account", account));
    }

    @Override
    public Integer addUserFeedback(UserFeedbackDTO userFeedbackDTO) {
        UserFeedback userFeedback = new UserFeedback();
        BeanUtil.copyProperties(userFeedbackDTO,userFeedback);
        userFeedback.setCreateTime(LocalDateTime.now());
        userFeedback.setProcessingResult(false);
        return baseMapper.insert(userFeedback);
    }
}
